<html>
<head>
	<title>METviewer Documentation</title>
	<link rel="stylesheet" type="text/css" href="mv_doc.css" />
	<link rel="shortcut icon" href="include/ral_icon.ico" type="image/x-icon"/>
</head>
<body>

<p class="loc" style="padding-top:10px">
<b>Location:</b> <a class="loc" href="index.html">Home</a> &#187; Installing METviewer
</p><hr/>

<h2>Installing METviewer</h2>

<p>
METviewer relies on the following tools.  These must be installed and tested prior to installing
	METviewer:<br/>
<ul>
	<li>
		<b class="inst">Java JDK 1.8+</b> -

	</li>
	<li>
		<b class="inst">ant</b> - <a href="http://ant.apache.org/bindownload.cgi" target="_blank">download</a> and install the latest version
	</li>
	<li>
		<b class="inst">MySQL</b> - <a href="http://dev.mysql.com/downloads/mysql/" target="_blank">download</a> and install the latest version.
        Use "SET GLOBAL max_allowed_packet=110000000;" by typing the command in MySQL and/or make the corresponding edit to /etc/my.cnf, so that the change persists after the next reboot.

    </li>
	<li>
		<b class="inst">Apache Tomcat</b> - 
			<a href="http://tomcat.apache.org/" target="_blank">download</a> and install the latest version; test the sample JSP web apps
	</li>
	<li>
		<b class="inst">R</b> - <a href="http://dev.mysql.com/downloads/mysql/" target="_blank">download</a> and install the latest version
	</li>
</ul>
</p>

<p>
<ol>

	<li class="inst">Configure the batch tool, database loader tool and web application:<br/>
		<ul>
			<li style="list-style-type:disc">edit [install]/metviewer/bin/mv_batch.sh:<br/>
				<ul>
					<li>set the variable JAVA to point at the jvm instance you would like to run</li>
					<li>set the variable METVIEWER to point at [install]/metviewer</li>
				</ul>
			</li><br/>
			<li style="list-style-type:disc">edit [install]/metviewer/bin/mv_load.sh:<br/>
				<ul>
					<li>set the variable JAVA to point at the jvm instance you would like to run</li>
					<li>set the variable METVIEWER to point at [install]/metviewer</li>
				</ul>
			</li><br/>
			<li style="list-style-type:disc">edit [install]/metviewer/webapp/metviewer/WEB-INF/classes/log4j.properties:<br/>
				<ul>
					<li>set log4j.appender.logfile.File setting to the absolute path of [install]/metviewer/log file</li>
				</ul>
			</li><br/>
			<li style="list-style-type:disc">edit [install]/metviewer/webapp/metviewer/WEB-INF/classes/mvservlet.properties:<br/>
				<ul>
					<li>set db.host to the MySQL database server host and port, e.g. db.ncep.gov:3306</li>
					<li>set db.user and db.password to the database username and password</li>
					<li>set cache.val to true/false depending on whether value caching should be enabled (recommend true)</li>
					<li>set cache.stat to true/false depending on whether statistics caching should be enabled (recommend true)</li>
					<li>set folders.plot_xml to the absolute path of [output_dir]/xml</li>
					<li>set folders.r_tmpl to the absolute path of [tomcat]/metviewer/R_tmpl</li>
					<li>set folders.r_work to the absolute path of [tomcat]/metviewer/R_work</li>
					<li>set folders.plots to the absolute path of [output_dir]/plots</li>
					<li>set folders.data to the absolute path of [output_dir]/data</li>
					<li>set folders.scripts to the absolute path of [output_dir]/scripts</li>
					<li>set redirect to the application name in url (ex. if the application URL is "http://www.dtcenter.org/met/metviewer/" tedirect is "metviewer")</li>
					<li>set url.output to the url to the output folder</li>
				</ul>
			</li><br/><br/>
		</ul>
	</li>
	<li class="inst">Configure the batch tool, database loader tool and web application:<br/>
		<ul>
			<li>Create output folders: [output_dir]/plots, [output_dir]/data, [output_dir]/scripts, [output_dir]/xml</li>
			<li>Include [output_dir] to Apache context</li>
			</ul>
	</li>
	<li class="inst">Build and deploy the application:<br/>
		<ul>
			<li style="list-style-type:disc">Build METviewer and the web application:<br/>
				<span class="term" style="padding-left:40px">$ cd [install]/metviewer</span><br/>		 
				<span class="term" style="padding-left:40px">$ ant</span><br/>
			</li><br/>
			<li style="list-style-type:disc">Install load_batch modual:<br/>
				<span class="term" style="padding-left:40px">$ cd [tomcat_base]/webapps</span><br/>		 
				<span class="term" style="padding-left:40px">$ cp [install]/dist/metviewer.war ./</span><br/>
			</li><br/>
			<li style="list-style-type:disc">Deploy the web app to tomcat:<br/>
							<span class="term" style="padding-left:40px">$ cd [install]/dist</span><br/>
							<span class="term" style="padding-left:40px">$ cp [install]/dist/batch_load.tar [load_batch_dir]</span><br/>
							<span class="term" style="padding-left:40px">$cd [load_batch_dir]</span><br/>
							<span class="term" style="padding-left:40px">$ tar -zxvf batch_load.tar</span><br/>
						</li><br/><br/>
		</ul>
	</li>
	<li class="inst">Create a METviewer database:<br/>
		<ul>
			<li style="list-style-type:disc">create a database to store MET data, which has the prefix 'mv_', e.g. mv_met_data:<br/>
				<span class="term" style="padding-left:40px">$ cd [install]/metviewer</span><br/>		 
				<span class="term" style="padding-left:40px">$ mysql -u[db_username] -p[db_password] -e'create database [db_name];'</span><br/>		 
				<span class="term" style="padding-left:40px">$ mysql -u[db_username] -p[db_password] [db_name] < sql/mv_mysql.sql</span><br/><br/>		 
			</li>
			<li style="list-style-type:disc">create an <a href="load.html">XML load specification</a> document which contains information about your MET data</li>
			<li style="list-style-type:disc">run the METviewer load tool using the XML load
				specification as input (called [load_xml] here) and monitor progress:<br/>
				<span class="term" style="padding-left:40px">$ cd [install]/metviewer</span><br/>		 
				<span class="term" style="padding-left:40px">$ bin/mv_load.sh [load_xml] [optional redirection of output, e.g. &> log/load_[date].log &]'</span><br/>		 
			</li><br/><br/>
		</ul>
	</li>

    <li class="inst">Install test directory (for development, optional):<br/>
    		<ul>
    			<li style="list-style-type:disc">check out test_data (.../apps/verif/metviewer_test_data/test_data/) from CVS and move test_data directory  to /d3/projects/METViewer/:<br/></li>
    			<li style="list-style-type:disc">create links to R script and sql files<br/>
    				<span class="term" style="padding-left:40px">$ cd /d3/projects/METViewer/test_data</span><br/>
    				<span class="term" style="padding-left:40px">$ ln -s /d3/projects/METViewer/src_dev/apps/verif/metviewer/R_tmpl R_tmpl</span><br/>
                    <span class="term" style="padding-left:40px">$ mkdir R_work</span><br/>
                    <span class="term" style="padding-left:40px">$ cd R_work</span><br/>
                    <span class="term" style="padding-left:40px">$ mkdir data</span><br/>
                    <span class="term" style="padding-left:40px">$ mkdir plots</span><br/>
                    <span class="term" style="padding-left:40px">$ mkdir scripts</span><br/>
                    <span class="term" style="padding-left:40px">$ ln -s /d3/projects/METViewer/src_dev/apps/verif/metviewer/R_work/include/ include</span><br/>
                    <span class="term" style="padding-left:40px">$ cd /d3/projects/METViewer/test_data/load_data/load</span><br/>
                    <span class="term" style="padding-left:40px">$ ln -s /d3/projects/METViewer/src_dev/apps/verif/metviewer/sql/mv_mysql.sql mv_mysql.sql</span><br/>

    			</li>
    		</ul>
    	</li>
</ol><br/><br/>
</p>


<a name="db_new"></a>
<h3>Making a Database Accessible in the METviewer Web Application</h3>
<p>
To make a new database accessible in the METviewer Web Application click on "Reload list of
	databases" button in the upper right corner of the main JSP page. The list of available databases should be updated and a new database should be in it<br/>
</p>

</body>
</html>
